home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
filefunctions
/
example5.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
4KB
|
115 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) Amiga C Club (ACC) */
/* -------------------------- ------------------ */
/* */
/* Manual: AmigaDOS Amiga C Club */
/* Chapter: File Functions Tulevagen 22 */
/* File: Example5.c 181 41 LIDINGO */
/* Author: Anders Bjerin SWEDEN */
/* Date: 93-03-15 */
/* Version: 1.0 */
/* */
/* Copyright 1993, Anders Bjerin - Amiga C Club (ACC) */
/* */
/* Registered members may use this program freely in their */
/* own commercial/noncommercial programs/articles. */
/* */
/***********************************************************/
/* This example demonstrates how to alter the protection flags */
/* on a file. The file we used in the previous example */
/* "HighScore.dat" will be protected and we will then try to */
/* delete it (unsuccessfully). We will then unprotect the file */
/* and try to delete it again (this time successfully). */
/* Include the dos library definitions: */
#include <dos/dos.h>
/* Now we include the necessary function prototype files: */
#include <clib/dos_protos.h> /* General dos functions... */
#include <stdio.h> /* Std functions [printf()...] */
#include <stdlib.h> /* Std functions [exit()...] */
/* Set name and version number: */
UBYTE *version = "$VER: AmigaDOS/FileFunctions/Example5 1.0";
/* Declared our own function(s): */
/* Our main function: */
int main( int argc, char *argv[] );
/* Main function: */
int main( int argc, char *argv[] )
{
/* A simple boolean variable: */
BOOL ok;
/* Protect the file: (We set the FIBF_DELETE flag which */
/* will remove the "d" bit. Note that the "e", "w" and */
/* "r" bits will be set and "s", "a" and "p" bits */
/* removed!) */
ok = SetProtection( "RAM:HighScore.dat", FIBF_DELETE );
/* Check if the file was successfully protected or not: */
if( ok )
printf( "File protected!\n" );
else
printf( "Error! Could not protect the file!\n" );
/* Try to delete the file: (Sould hopefully not work!) */
ok = DeleteFile( "RAM:HighScore.dat" );
/* Check if the file was deleted or not: */
if( ok )
printf( "File deleted!\n" );
else
printf( "Error! Could not delete the file!\n" );
/* Unprotect the file: (We set do not set the FIBF_DELETE */
/* flag and consequently the "d" bit will be added. Note */
/* that the "e", "w" and "r" bits will be set and "s", */
/* "a" and "p" bits removed!) */
ok = SetProtection( "RAM:HighScore.dat", NULL );
/* Check if the file was successfully unprotected or not: */
if( ok )
printf( "File unprotected!\n" );
else
printf( "Error! Could not unprotect the file!\n" );
/* Try to delete the file: (Sould hopefully work this time!) */
ok = DeleteFile( "RAM:HighScore.dat" );
/* Check if the file was deleted or not: */
if( ok )
printf( "File deleted!\n" );
else
printf( "Error! Could not delete the file!\n" );
/* The End! */
exit( 0 );
}